home *** CD-ROM | disk | FTP | other *** search
/ Point Programming 1 / PPROG1.ISO / pascal / swag / printing.swg / 0019_Checking For Printer.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1993-08-17  |  1.5 KB  |  66 lines

  1. program chkprinter;
  2.  
  3. uses dos,crt;
  4.  
  5. var
  6.   lprn: integer;
  7.   st : string;
  8.  
  9.  
  10. function printerok(lprn : integer) : boolean;
  11.  
  12. var ok   : boolean;
  13.     regs : registers;
  14.     st   : string;
  15.     code : byte;
  16.  
  17. begin                 {printerok}
  18.   ok := false;
  19.   dec(lprn);
  20.   if ((lprn >= 0) and (lprn <= 2)) then
  21.     repeat
  22.       regs.ah := 2;
  23.       regs.dx := lprn;
  24.       intr($17, regs);
  25.       code := regs.ah;
  26.       if code <> $90
  27.         then
  28.           begin
  29.             case code of
  30.      $02, $4A : st := '        Printer is not connected        ';
  31.      $00, $10,
  32.      $18, $58 : st := '           Printer is offline           ';
  33.      $28, $38 : st := '         Printer is out of paper        ';
  34.      $88, $C8 : st := '          Printer is turned off         ';
  35.            else st := '       Output device is not ready       ';
  36.            end;      {case}
  37.            GoToXY(1,1);
  38.            WriteLn(st);
  39.            WriteLn(' ');
  40.            WriteLn('Please correct the error');
  41.            WriteLn('or press a key to continue')
  42.           end
  43.         else
  44.           ok := true;
  45.     until ok or keypressed;
  46.   if ok then printerok := ok
  47. end;                  {printerok}
  48. {**********************************************************************}
  49.  
  50.   begin
  51.  
  52.   ClrScr;
  53.  
  54.   if paramcount <> 0
  55.     then begin
  56.            st := copy(paramstr(1), 1, 1);
  57.            lprn := ord(st[1]) - 48
  58.          end
  59.     else lprn := 1;
  60.  
  61.   if printerok(lprn) then
  62.      writeln('Printer OK')
  63.   else
  64.      writeln('Printer not ok')
  65. end.
  66.